#include<stdio.h>
#include<math.h>
int search(int n){
	int a,b,c,count=0;
	for(int i=101;i<n;i++){
		if(sqrt(i)==(int)sqrt(i)){
			a=i%10;
			b=i/10%10;
			c=i/10/10;
			if(a==b||a==c||b==c)
			count++;
		}
	}
	return count;
}
int main(){
	int n;
	scanf("%d",&n);
	printf("%d",search(n));
	return 0;
}
